package Operations;
import Book.Book;
import Book.BookList;

import java.util.Scanner;

public class AddOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        //增加图书
        System.out.println("新增图书！");
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入你要新增的图书的名字：");
        String bookname = sc.nextLine();
        System.out.println("请输入你要新增的图书的作者：");
        String author = sc.nextLine();
        System.out.println("请输入你要新增的图书的价格：");
        int price = sc.nextInt();
        //读取回车
        sc.nextLine();
        System.out.println("请输入你要新增的图书的类型：");
        String type = sc.nextLine();

        int size = bookList.getNumBook();
        Book book = new Book(bookname,author,price,type);
        bookList.setBooks(book, size);
        bookList.setNumBook(size + 1);
    }
}
